home *** CD-ROM | disk | FTP | other *** search
- /* This little utility will turn a file version into its comment.
-
- Who needs this?
- Someone who uses some kind of directory utility which displays file
- comment but not version. You can select file, click v2c, rescan
- the directory and just read the comment.
-
- Why is this useful?
- Sometimes you get some kind of a short utility which you allready have
- but filsizes dont match. Its a short way to find out which one is newer.
-
- How do I use it?
- Usage is "v2c <Filename>" (no Wildcards permitted)
-
- Why no wild cards?
- There is no need for that if your directory utility supports a single
- call for every item you selected. If it doesn't, bad luck :)
-
- This code is crap!
- It is my gift to you.
-
- This is just what I have been waiting for and I want to contact the
- author and congratulate him!
- Great! Glad that at least someone is happy. If you like this, use it
- or want a better version, write to me and I'll be happy to help you.
-
- My address is:
-
- Drago Fiser
- Plecnikova 5
- 62000 Maribor
- Slovenia, Europe
- Tel. +386 (0)62 31956
-
- E-mail: Drago.Fiser@uni-mb.si
-
- */
-
- #include <proto/dos.h>
-
- int GetVersion(BPTR fil,char *filcomm)
- { char d, *versionstring="$VER: v2c 1.00 22.11.1994 by Drago Fiser";
- int i=0;
- ULONG filelength, st;
-
- Seek(fil,0,OFFSET_END);
- filelength=Seek(fil,0,OFFSET_BEGINNING);
- for (st=0; st<filelength; st++) {
- if ((d= FGetC(fil)) ==versionstring[i]) {
- if ((++i)==5) { FGets(fil,filcomm,80); return(1); }
- } else i=0;
- }
- return(0);
- }
-
- main( int argc, char **argv)
- {
- char filcomm[80];
- BPTR Fil;
-
- if (argc==2) {
- if (Fil=Open(argv[1],MODE_OLDFILE)) {
- if (GetVersion(Fil,filcomm)) SetComment(argv[1],filcomm);
- else SetComment(argv[1],".");
- Close(Fil);
- } else PutStr("File does not exist.\n");
- } else PutStr("Wrong number of arguments.\n");
- }
-